import { ID, PaginationParam, PaginationResult } from "/@/api/models";
import req from "/@/api/req";
import { getPage } from "/@/api/curd";

export enum Api {
  userDynamics = "user-dynamics",
  userComments = "user-comments",
  reviewOffline = "user-dynamics/review-offline",
}

export interface DynamicItem {
  createTime: string;
  dynamicsContent: string;
  dynamicsUrl: string;
  id: ID;
  nickName: string;
  releaseTime: string;
  status: number;
  userId: ID;
}

export interface CommentItem {
  commentsContent?: string;
  contentReplied?: string;
  createTime?: string;
  dynamicsId?: ID;
  id?: ID;
  nickName?: string;
  replyId?: ID;
  replyUserId?: ID;
  replyUserNickName?: String;
  status?: number;
  userId?: ID;
}

export function getUserDynamics(params: PaginationParam<DynamicItem>) {
  return getPage<DynamicItem>(Api.userDynamics, params);
}

export function reviewOffline(data: DynamicItem) {
  return req.put({
    url: Api.reviewOffline,
    data,
  });
}

export function getUserComments(params: PaginationParam<CommentItem>) {
  return getPage<CommentItem>(Api.userComments, params);
}

export function updateUserComment(data: CommentItem) {
  return req.put({
    url: Api.userComments,
    data,
  });
}
